package com.gxh.shiro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxh.shiro.entity.User;
import com.gxh.shiro.mapper.UserMapper;
import com.gxh.shiro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Xiaohong X Gou
 * @createTime 2023-04-11 16:46
 * @description
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    public User getUserInfoByName(String name) {
        QueryWrapper<User> wrapper=new QueryWrapper<>();
        wrapper.eq("name",name);
        User user = userMapper.selectOne(wrapper);
        return user;
    }
    //根据用户名查询角色信息
    @Override
    public List<String> getUserRoleInfo(String principal) {
        List<String> userRoleInfo = userMapper.getUserRoleInfo(principal);
        return userRoleInfo;
    }
    //获取用户角色权限信息
    @Override
    public List<String> getUserPermissionInfo(List<String> roles) {
        List<String> Permissions = userMapper.getUserPermissionsInfoMapper(roles);
        return Permissions;
    }
}
